﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Common.Library;
using System.Reflection;
using Common.Utilities;

namespace OnlineVideos.Views
{
    public class settingclass
    {
          public string SettingName
        {
            get;
            set;
        }
        public string SettingValue
        {
            get;
            set;
        }
    }
    public partial class MusicSettings : PhoneApplicationPage
    {
        List<settingclass> settingclasslist = new List<settingclass>();
        public MusicSettings()
        {
            InitializeComponent();
            Loaded += MusicSettings_Loaded;
        }
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            try
            {
                FlurryWP8SDK.Api.EndTimedEvent("MusicSettings Page");
            }
            catch (Exception ex)
            {

                Exceptions.SaveOrSendExceptions("Exception in OnNavigatedFrom Method In MusicSettings.cs file.", ex);
            }
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            try
            {
                FlurryWP8SDK.Api.LogPageView();
            }
            catch (Exception ex)
            {

                Exceptions.SaveOrSendExceptions("Exception in OnNavigatedTo Method In MusicSettings.cs file.", ex);
            }
        }
        void MusicSettings_Loaded(object sender, RoutedEventArgs e)
        {
            LoadAds();
            try
            {
                FlurryWP8SDK.Api.LogEvent("MusicSettings Page", true);
                Assembly DataAssembly = Assembly.Load(new AssemblyName("Common.Library"));
                Type ClassType = DataAssembly.GetType("Common.Library" + "." + "AppResources");
                PropertyInfo[] ConditionProperty = ClassType.GetProperties().ToArray();
                foreach (PropertyInfo property in ConditionProperty)
                {
                    settingclass settingclass = new settingclass();
                    if (property.PropertyType != typeof(Uri))
                    {
                        settingclass.SettingName = property.Name.ToString() + " : ";
                        settingclass.SettingValue = (property.GetValue(property) != null ? property.GetValue(property).ToString() : null);
                        if (settingclass.SettingValue != null)
                            settingclasslist.Add(settingclass);
                    }
                }
                lbxsettings.ItemsSource = settingclasslist;
            }
            catch (Exception ex)
            {
                Exceptions.SaveOrSendExceptions("Exception in MusicSettings_Loaded Method In MusicSettings.cs file.", ex);
            }
        }
        private void LoadAds()
        {
            try
            {
                PageHelper.LoadAdControl(LayoutRoot, adstackpl, 2);
            }
            catch (Exception ex)
            {
                Exceptions.SaveOrSendExceptions("Exception in LoadAds Method In SongDetails file", ex);
                string excepmess = "Exception in LoadAds Method In SongDetails file.\n\n" + ex.Message + "\n\n StackTrace :- \n" + ex.StackTrace;
            }

        }

    }
}